 
#pragma once


#include "export.h"
#include "matUiEditor.h"

namespace Ogitors
{

class PluginExport COSMEntityEditor : public CNodeEditor
{
    friend class COSMEntityEditorFactory;
public:

	virtual void            GetObjectUserData(std::ofstream &outfile);
    virtual void            GetObjectProperties(Ogre::NameValuePairList &retList);
	virtual void			SetHandle(void *objHandle,bool display);
    virtual bool			SetupPropertiesWnd();
	virtual void            FreeHandle();
    virtual void            ShowBoundingBox(bool bShow);
	virtual Ogre::AxisAlignedBox GetAABB() {return m_EntityHandle->getBoundingBox();};
    /// Overridden by Editor Objects to Import Object Dependant Properties
    virtual CBaseEditor    *Restore(Ogre::NameValuePairList &retList);
    /// Gets the Handle to encapsulated object
    inline virtual void    *GetHandle() {return static_cast<void*>(m_EntityHandle);};
    /// Returns the Factory associated with this object
	static CBaseEditorFactory *GetFactory();
    /// Returns the Factory associated with this object can be overridden
	virtual CBaseEditorFactory *GetFactoryDynamic();
	virtual Ogre::String	GetMeshFileName() {return m_EntityHandle->getMesh()->getName();};
    int                     GetNumSubEntities() {return m_EntityHandle->getNumSubEntities();};
    virtual Ogre::String	GetSubMaterialName(int subEntityID);
	virtual bool			GetSubVisible(int subEntityID);
	virtual Ogre::SceneManager *GetSceneManager() {return m_EntityHandle->_getManager();};
	/// Gets Object's Cast Shadows Property 
	virtual bool			GetCastShadows() {return m_EntityHandle->getCastShadows();};

	virtual void            SetCastShadows(int BIND_ID,Ogre::String val,bool refresh);

    //Custom Set Functions: Starting at MAXIMUM_BINDING_FUNCTION
	virtual void	SetSubMaterial(int subid,Ogre::String val);
	virtual void	SetSubVisible(int subid,bool val);

protected:
	Ogre::Entity *m_EntityHandle;
	matUiEditor    *      m_matEditor;
	matEditorList m_matEditorList;

	COSMEntityEditor(Ogre::String typestring = "OSMEntity Object", EDITORTYPE etype = ETYPE_ENTITY);
	virtual     ~COSMEntityEditor() {};
	virtual bool HandleCustomFunction(int BIND_ID,Ogre::String val);
};

class PluginExport COSMEntityEditorFactory: public CBaseEditorFactory
{
public:
  COSMEntityEditorFactory() {};
  virtual ~COSMEntityEditorFactory() {};
  virtual CBaseEditor *CreateObject(CBaseEditor **parent, Ogre::NameValuePairList &params);
};

}
